﻿
namespace Marmat.Forms
{
    public partial class BaseGrid
    {
        internal class Help
        {

            public static DevExpress.XtraGrid.Columns.GridColumn get_FocusedColumn(DevExpress.XtraGrid.Views.Base.BaseView View)
            {
                DevExpress.XtraGrid.Columns.GridColumn Result = null;
                if (View is DevExpress.XtraGrid.Views.Grid.GridView)
                {
                    Result = ((DevExpress.XtraGrid.Views.Grid.GridView)View).FocusedColumn;
                }
                else if (View is DevExpress.XtraGrid.Views.BandedGrid.BandedGridView)
                {
                    Result = ((DevExpress.XtraGrid.Views.BandedGrid.BandedGridView)View).FocusedColumn;
                }
                else if (View is DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView)
                {
                    Result = ((DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView)View).FocusedColumn;
                }

                return Result;
            }

            /// <summary>
            /// 返回指定坐标位置的单元格的显示内容。
            /// </summary>
            /// <param name="Row">行坐标，计算的时候包括分组行。</param>
            /// <param name="Column">列坐标</param>
            /// <returns></returns>
            /// <remarks></remarks>
            internal static string GetRowCellDisplayText(DevExpress.XtraGrid.Views.Base.BaseView View, int Row, Views.Grid.Column Column)
            {
                string Result = null;
                if (View is DevExpress.XtraGrid.Views.Grid.GridView)
                {
                    Result = ((DevExpress.XtraGrid.Views.Grid.GridView)View).GetRowCellDisplayText(Row, Column.GridColumn);
                }
                else if (View is DevExpress.XtraGrid.Views.BandedGrid.BandedGridView)
                {
                    Result = ((DevExpress.XtraGrid.Views.BandedGrid.BandedGridView)View).GetRowCellDisplayText(Row, Column.GridColumn);
                }
                else if (View is DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView)
                {
                    Result = ((DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView)View).GetRowCellDisplayText(Row, Column.GridColumn);
                }

                return Result;
            }

            /// <summary>
            /// 获得或设置指定坐标位置的单元格的值。
            /// </summary>
            /// <param name="Row">行坐标，计算的时候包括分组行。</param>
            /// <param name="Column">列坐标</param>
            /// <returns></returns>
            /// <remarks></remarks>
            internal static object GetRowCellValue(DevExpress.XtraGrid.Views.Base.BaseView View, int Row, Views.Grid.Column Column)
            {
                object Result = null;
                if (View is DevExpress.XtraGrid.Views.Grid.GridView)
                {
                    Result = ((DevExpress.XtraGrid.Views.Grid.GridView)View).GetRowCellValue(Row, Column.GridColumn);
                }
                else if (View is DevExpress.XtraGrid.Views.BandedGrid.BandedGridView)
                {
                    Result = ((DevExpress.XtraGrid.Views.BandedGrid.BandedGridView)View).GetRowCellValue(Row, Column.GridColumn);
                }
                else if (View is DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView)
                {
                    Result = ((DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView)View).GetRowCellValue(Row, Column.GridColumn);
                }

                return Result;
            }
        }
    }
}